-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add users support #6
Draft
ooliver1
wants to merge
27
commits into
next
Choose a base branch
from
ooliver1/feat/users
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EnokiUN
requested changes
Jun 17, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds users support, added in https://github.com/eludris/eludris/tree/enoki/users. This has not been merged into
next
yet, so neither will this PR.Details in order of diff:
Configuration is stored in
~/.config/pilfer/Pilfer.toml
(user token), like the Eludris CLI in eludris/eludris#79. This is too, configurable viaPILFER_CONF
.Documentation in the README has been added for existing and new keybinds.
Authentication is done once
HELLO
has been received.heartbeat_interval
is actually in milliseconds, not seconds, which was an issue since pilfer would disconnect and reconnect.A list has been added to the right of the messages box, which is togglable using
Ctrl + U
. This is a list of currently online users (notOFFLINE
) - soONLINE
,IDLE
, andBUSY
. It is stored as a hashmap ofid: User
for now. This is so it can be updated easily and quickly when receiving aPRESENCE_UPDATE
. It is not necessary to store this in a simplified structure containing display name and status, since theUser
struct is already small. If a user is not known, it is fetched from the API and added to the hashmap.Instances of
msg.message.content
have been altered to usemsg.message.content
as in todel, this is a flattened common struct. ABox
is used aroundPilfer::Eludris()
as eludris message structs are not as small as they used to be, and this is passed around a lot.The instance version is checked against the
pilfer
package version. Right now, it must be0.4.0-alpha1
or greater to not fail. If the instance is lower, an error is printed, suggesting usage ofINSTANCE_URL
for the next instance or some other instance. If the instance is higher, an error is thrown, suggesting updatingpilfer
.run_app
is used underspawn_blocking
as it should be ran in an executor forterminal.draw(|f| ui(f, &app))
to use locks in a blocking manner. This means thatterminal
is then passed back to the caller, to avoidArc
+Mutex
usage.run_app
contains a closure with the inner logic, as the terminal also needs to be returned. This avoids having to return(terminal, err)
on error, andterminal
on success. Abool
is used for if the loop should continue, or not (Ctrl + C
).MessageResponse
has been changed toResponse<T>
to be more universal, as it can then be more universally used for API errors.The user list is rendered inside the same chunk as
messages
, so it can then be optionally split horizontally. The users list is locked at 20 characters to be big enough to read, but small enough to not be intrusive.Ctrl + U
can still get rid of it in stupidly small terminal windows.Users are authenticated using an initial
Y/n
prompt for logging in or registering. Username/email is then prompted in both cases, and password viarpassword
for cross-platform hidden input. In the signup case, ifInstanceInfo.email_address
exists, the user is reminded to usepilfer --verify
with their email verification code.platform
is the OS's human lowercase name, such aslinux
,windows
,macos
, ..., andclient
ispilfer
.This is a Code Change